package com.gt.quality.base.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @description: 通用响应
 * @author: makeJava
 * @since JDK21
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseLimitResponse<T extends Serializable> extends BasePage {

    //状态码
    private int code;

    //提示信息
    private String msg;

    /**
     * Description: 当前页数据
     */
    private List<T> responseBody;

    /**
     * Description:  总条数
     */
    private long totalNum;


    /**
     * Description:  总页数
     */
    private long pageCount;


    public static <T extends Serializable> BaseLimitResponse<T> getInstance() {
        return new BaseLimitResponse<>();
    }

    /**
     * Description: 获取响应对象
     *
     * @param responseBody 当前页数据
     * @param totalNum     总数据
     * @param pageCount    总页数
     * @param pageIndex    当前页
     * @param pageSize     每页展示数据大小
     * @author: makeJava
     * @date: 2026-12-02 15:01:48
     */
    public static <T extends Serializable> BaseLimitResponse<T> getInstance(List<T> responseBody, long totalNum, long pageCount, long pageIndex, long pageSize) {
        BaseLimitResponse<T> response = new BaseLimitResponse<>();
        response.setResponseBody(responseBody);
        response.setPageCount(pageCount);
        response.setTotalNum(totalNum);
        response.setPageSize(pageSize);
        response.setPageIndex(pageIndex);
        response.setCode(Resp.SUCCESS);
        response.setMsg(Resp.SUCCESS_STR);
        return response;
    }


}

